package _08作业.t5;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class T4Client {
    public static void main(String[] args) throws IOException {
        //创建客户端
        Socket socket = new Socket("127.0.0.1",8888);
        //创建socket输入流
        OutputStream socketOutputStream = socket.getOutputStream();

        //键盘输入
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名和密码，格式：用户名=密码");
        String line = scanner.nextLine();
        PrintStream printStream = new PrintStream(socketOutputStream);
        printStream.println(line);

        //返回登录信息
        InputStream socketInputStream = socket.getInputStream();
        InputStreamReader isr = new InputStreamReader(socketInputStream);
        BufferedReader br = new BufferedReader(isr);
        String readLine = br.readLine();
        System.out.println(readLine);

        br.close();
        isr.close();
        socketInputStream.close();
        printStream.close();
        socketOutputStream.close();
        socket.close();
    }
}
